package com.example.demo.api;

import com.example.demo.entity.AddressBook;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 通用返回通讯录信息
 *
 * @author wzw
 * @date 2022/4/27 16:31
 */
@Data
public class AddressBookResponse {
    private int page;
    private int pageSize;
    private long total;
    private int totalPage;
    private List<AddressBook> addressBooks;
    private String resultMessage;

    public AddressBookResponse(List<AddressBook> addressBooks, int page, int pageSize, long total, int totalPage) {
        this.page = page;
        this.pageSize = pageSize;
        this.total = total;
        this.totalPage = totalPage;
        this.addressBooks = addressBooks;
        if (addressBooks.isEmpty()) {
            this.resultMessage = "没有分页消息";
        } else {
            this.resultMessage = "返回分页消息";
        }

    }


    public AddressBookResponse(AddressBook addressBook, String resultMessage, long total) {
        List<AddressBook> addressBooks = new ArrayList<>();
        addressBooks.add(addressBook);
        this.page = 0;
        this.pageSize = 0;
        this.total = total;
        this.totalPage = 0;
        this.addressBooks = addressBooks;
        this.resultMessage = resultMessage;
    }
}
